﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using WMSSoft.Lib.Basic;
using WMSSoft.Lib.WinKStart.ViewModel;

namespace WMSSoft.Lib.WinKStart.Abstract
{
    public abstract class CSettingsBaseViewModel : CCommandViewModel
    {
        public event EventHandler ViewModel_OkClick;
        public event EventHandler ViewModel_CloseClick;
        public event EventHandler ViewModel_ApplyClick;

        public CSettingsBaseViewModel() 
        {
            m_oCommands.Add(new CSingleCommandViewModel(LanguageStrings.GetText("Ok"), new CDelegatingCommand(Delegate => this.Cmd_Exec_OkClick())));
            m_oCommands.Add(new CSingleCommandViewModel(LanguageStrings.GetText("Close"), new CDelegatingCommand(Delegate => this.Cmd_Exec_CloseClick())));
            m_oCommands.Add(new CSingleCommandViewModel(LanguageStrings.GetText("Apply"), new CDelegatingCommand(Delegate => this.Cmd_Exec_ApplyClick())));
        }

        void Cmd_Exec_OkClick()
        {
            if (ViewModel_OkClick != null) ViewModel_OkClick(this, EventArgs.Empty);
        }

        void Cmd_Exec_CloseClick()
        {
            if (ViewModel_CloseClick != null) ViewModel_CloseClick(this, EventArgs.Empty);
        }

        void Cmd_Exec_ApplyClick()
        {
            if (ViewModel_ApplyClick != null) ViewModel_ApplyClick(this, EventArgs.Empty);
        }

        public CSingleCommandViewModel Cmd_OkClick
        {
            get { return m_oCommands[0]; }
        }

        public CSingleCommandViewModel Cmd_CloseClick
        {
            get { return m_oCommands[1]; }
        }

        public CSingleCommandViewModel Cmd_ApplyClick
        {
            get { return m_oCommands[2]; }
        }
    }

}
